package com.yf.htmlsourceview;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class StringUtil {

	public static String fromStream(InputStream is) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		
		int len = -1;
		byte[] buf = new byte[1024];
		try {
			while ((len = is.read(buf)) != -1) {
				baos.write(buf, 0, len);
			}
			byte[] byteArray = baos.toByteArray();
			baos.close();
			
			return new String(byteArray);
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}
}
